package com.bst.bsj.common.dal.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.bst.bsj.common.dal.daointerface.MerchantDAO;
import com.bst.bsj.common.dal.dataobject.Merchant;
import com.bst.bsj.common.maopu.enums.MemberStatus;
import com.sylinxsoft.tools.dao.impl.CommonBaseDAOImpl;


@Service("merchantDAO")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class MerchantDAOImpl extends CommonBaseDAOImpl implements MerchantDAO {
    public Merchant selectByMobile(String mobile) {
        Map map = new HashMap();
        map.put("mobile", mobile);
        map.put("status", MemberStatus.ON.getCode());
        return  (Merchant) this.getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_QUERY", map);
    }


    @Override
    public List<Merchant> selectAll(Map paramMap) {
      return (List<Merchant>) this.getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_QUERY_PAGE", paramMap);

    }

    @Override
    public Long getCounts(Map paramMap) {
      
      return (Long) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_QUERY_COUNT", paramMap);    
    }

    @Override
    public Long save(Merchant merchant) {
     
     return (Long) this.getSqlMapClientTemplate().insert(getNameSpace() + ".MS_INSERT", merchant);
    }

    @Override
    public int delete(Long id) {
      
      return getSqlMapClientTemplate().delete(getNameSpace() + ".MS_DELETE_BY_ID", id);
    }

    @Override
    public Merchant query(Long id) {
      
      return (Merchant) this.getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_SELECT", id);
    }

    @Override
    public int update(Merchant merchant) {

     return getSqlMapClientTemplate().update(getNameSpace() + ".MS_UPDATE", merchant);
    }


    @Override
    public List<Merchant> getMerchantByRoleId(Long roleId) {
      Map paramMap=new HashMap();
      paramMap.put("roleId", roleId);
      return (List<Merchant>) this.getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_GET_BY_ROLEID", paramMap);
    }

    
}
